/**
 * 您的公司.com
 * Copyright (c) 2018-2018 All Rights Reserved.
 */
package com.mei.demo;

import java.util.List;

import redis.clients.jedis.Jedis;

/**
 * 
 *
 * @author mei.xiaoliang@qq.com
 */
public class RedisListJava {

    @SuppressWarnings("resource")
    public static void main(String[] args) {
        // 连接本地的 Redis 服务
        Jedis jedis = new Jedis("localhost");
        System.out.println("连接成功");
        // 存储数据到列表中
        for (int i = 0; i < 500000; i++) {
            jedis.lpush("site-list", "Runoob" + i);
        }
        // 获取存储的数据并输出
        List<String> list = jedis.lrange("site-list", 0, 2);
        for (int i = 0; i < list.size(); i++) {
            System.out.println("列表项为: " + list.get(i));
        }
    }

}